mixin nav(currentPath, navItems, title, headings)
  div.sidebar-container
    ul.sidebar-elements
      if navItems
        if navItems.length === 1
          +navContent(headings, 0, currentPath)
        else
          +navRec(currentPath, navItems, title, 2, headings)

mixin navRec(currentPath, navItems, title, depth, headings)
  for navItem in navItems
    - if(navItem.metadata.showInNav !== false)
      - var isCurrentFile = navItem.path === currentPath;
      - var className = ['sidebar-element', ('level-h' + depth), (isCurrentFile ? 'navItem-active' : 'navItem'), currentPath.split('/')[0]];
      - var activeClass = isCurrentFile ? 'navItem-active' : '';
      li(class=className)
        if navItem.title === 'InstantSearch'
          a(href=navItem.path class=activeClass)='<InstantSearch>'
        else
          a(href=navItem.path class=activeClass)=navItem.title
        ul
          if(isCurrentFile)
            +navContent(headings, depth, currentPath)

mixin navContent(headings, currentDepth, currentPath)
  if headings && headings.length > 1
    each item in headings
      - var level = parseFloat(/h([0-9]+)/.exec(item.tag)[1]);
      - var actualLevel = level + currentDepth - 1;
      - var className = ['sidebar-element', 'level-h' + actualLevel]
      li(class=className)
        a(href=`${currentPath}#${item.id}`)= item.text
